# -*- coding:utf-8 -*-
# 函数

# 函数定义
def fib(n):
    '''生成斐波那数列'''
    a, b = 0, 1
    while a < n:
        print(b)
        a, b = b, a + b
    else:
        print('done')


f = fib
f(5)


# 函数默认值积累现象

def f(a, L=[]):
    L.append(a)
    return L
print(f(1))
print(f(2))
print(f(3))


def f(a, L = None):
    if (L == None):
        L = []
    L.append(a);
    return L

print(f(1))
print(f(2))
print(f(3))

# 关键字参数的调用形式
def fun(param1, param2 = 1, param3 = []):
    print(param1, param2,param3)

fun(10) # (10, 1, [])
fun(param1=10) # (10, 1, [])
fun(param3=[1],param1=10) #(10, 1, [1])